/*
 * Copyright (C) 2017 Honeywell, Inc. All Rights Reserved.
 */

package org.thanos.demo.bootstrap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Configuration
@SpringBootApplication
@EnableScheduling
@ComponentScan("org.thanos.demo")
@ImportResource("classpath:spring/applicationContext.xml")
public class DubboServiceApp {

    private static final Logger LOGGER = LoggerFactory.getLogger(DubboServiceApp.class);

    public static void main(String[] args) {
        new SpringApplicationBuilder(DubboServiceApp.class)
                .web(WebApplicationType.NONE)
                .run(args);
    }

    @Scheduled(fixedRate = 1000 * 60 * 60 * 24)
    public void recordTime() {
        LOGGER.info("local time is {}.", LocalDateTime.now().format(DateTimeFormatter.ISO_DATE));
    }
}
